package com.java46.admin.user.service;

import com.java46.admin.user.dao.UserDaoT;
import com.java46.admin.user.entity.UsersEntity;
import com.java46.admin.user.util.Page;

import java.util.List;

public class UserServiceT {
    UserDaoT userDaoT = new UserDaoT();

    /**
     * 查询所有用户
     * @param currentPage 当前页
     * @param pageSize 每页显示条数
     * @param openId 模糊查询条件
     * @return
     */
    public Page queryForPage(int currentPage,int pageSize,String openId) {
        // TODO Auto-generated method stub
        Page page = new Page();
        //总记录数
        int allRow = userDaoT.getAllRowCount(openId);
        //当前页开始记录
        int offset = page.countOffset(currentPage,pageSize);
        //分页查询结果集
        List<UsersEntity> list = userDaoT.queryForPage(offset, pageSize,openId);
        page.setPageNo(currentPage);
        page.setPageSize(pageSize);
        page.setTotalRecords(allRow);
        page.setList(list);
        return page;
    }

    /**
     * 删除
     * @param openId
     * @return
     */
    public int removeUser(String openId){
        return userDaoT.removeUser(openId);
    }


}
